package com.wyl.base.controller;

import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.wyl.base.common.ResponseData;
import com.wyl.base.dto.UserDto;
import com.wyl.base.req.UserReq;
import com.wyl.base.vo.UserVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

/**
 * @Description
 * @Author WuYiLong
 * @Date 2024/2/21 11:22
 */
@Tag(name = "用户api")
@RestController
@RequestMapping(value = "user")
public class UserController {

    @Operation(summary = "保存用户")
    @PostMapping(value = "saveUser")
    public ResponseData saveUser(@RequestBody UserDto userDto) {
        return ResponseData.success();
    }

    @Operation(summary = "用户分页")
    @GetMapping(value = "pageUser")
    public ResponseData<UserVo> pageUser(@ParameterObject UserReq userReq) {
        return ResponseData.success();
    }

    @Operation(summary = "根据用户id查询")
    @Parameter(name = "id",description = "用户id",in= ParameterIn.PATH)
    @GetMapping(value = "getUserById/{id}")
    public ResponseData<UserVo> getUserById(@PathVariable("id") Long id) {
        return ResponseData.success();
    }

    @Operation(summary = "根据用户名称查询")
    @Parameter(name = "name",description = "用户名称",in = ParameterIn.QUERY)
    @GetMapping(value = "getUserByName")
    public ResponseData<UserVo> getUserByName(String name) {
        return ResponseData.success();
    }

    @Operation(summary = "根据用户名称和年龄查询")
    @Parameters(value = {
            @Parameter(name = "name",description = "用户名称",in = ParameterIn.QUERY),
            @Parameter(name = "age",description = "用户年龄",in = ParameterIn.QUERY),
    })
    @GetMapping(value = "getUserByNameAndAge")
    public ResponseData<UserVo> getUserByNameAndAge(String name,Integer age) {
        return ResponseData.success();
    }
}
